/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	heyong 
 * 
 * <p>描   述  :   PrevenManagementServiceImpl.java for com.pengtu.gsj.service.impl.jsbz    </p>
 * 
 * <p>最后修改 : $: 2017年8月10日-上午9:18:23 v 1.0.0	 heyong   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.jsbz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.jsbz.PrevenManagementDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.jsbz.PrevenManagement;
import com.pengtu.gsj.service.jsbz.PrevenManagementService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * PrevenManagementServiceImpl
 * 
 * 2017年8月10日 上午9:18:23
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class PrevenManagementServiceImpl implements PrevenManagementService{
	
	@Autowired
	private PrevenManagementDao prevenManagementDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void savePrevenManagement(PrevenManagement prevenManagement){
		prevenManagementDao.save(prevenManagement);
	}
	
	@Override
	public Page<PrevenManagement> findPrevenManagement(Page<PrevenManagement> page, final QueryFilter queryFilter){
		return prevenManagementDao.findPage(page, queryFilter);
	}
	
	@Override
	public PrevenManagement getPrevenManagementById(String id){
		return prevenManagementDao.get(id);
	}
	
	@Override
	public void  delatePrevenManagement(PrevenManagement prevenManagement){
		if(prevenManagement.getAttachments() != null){
			for(Attachment attachment : prevenManagement.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		prevenManagementDao.delete(prevenManagement);
	}
	
	@Override
	public boolean checkTecYear(String testYear, String id){
		return prevenManagementDao.checkProperty("testYear", testYear, id);
	}
	
}
